package com.zzyl.controller;


import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.entity.NursingPlan;
import com.zzyl.service.NursingLevelService;
import com.zzyl.service.NursingPlanService;
import com.zzyl.service.impl.NursingLevelServiceImpl;
import com.zzyl.vo.NursingLevelVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/nursingLevel")
@Api(tags = "护理项目")
public class NursingLevelController extends BaseController {
    @Autowired
    private NursingLevelService nursingLevelService;
    @Autowired
    private NursingLevelServiceImpl nursingLevelServiceImpl;

    @GetMapping("/listAll")
    @ApiOperation("查询所有护理等级")
    public ResponseResult listAll() {
        List<NursingLevelVo> vo = nursingLevelService.listAll();
        return success(vo);
    }

    @ApiOperation("新增护理等级")
    @PostMapping("/insert")
    public ResponseResult insert(NursingLevelDto nursingLevelDto) {
        log.info("拿到的Dto{}", nursingLevelDto);
        nursingLevelService.insert(nursingLevelDto);
        return success();
    }

    @GetMapping("/listByPage")
    @ApiOperation("护理等级条件分页查询")
    public ResponseResult listByPage(@ApiParam(value = "护理等级名称" )  String name,
                                     @ApiParam(value = "护理等级状态") Integer status,
                                     @ApiParam(value = "页码")@RequestParam(defaultValue = "1",required = false) Integer page,
                                     @ApiParam(value = "每页大小")@RequestParam(defaultValue = "10",required = false) Integer pageSize) {
        log.info("护理等级条件分页查询的条件{},{},{},{}",name,status,page,pageSize);
        PageResponse<NursingLevelVo> vo = nursingLevelService.listByPage(name,status,page,pageSize);
        return success(vo);
    }

    @GetMapping("/{id}")
    @ApiOperation("护理等级ID查询")
    public ResponseResult getById(@PathVariable Integer id) {
        log.info("护理等级ID查询{}",id);
        NursingLevelVo vo = nursingLevelService.getById(id);
        return success(vo);
    }


    @GetMapping("/update")
    @ApiOperation("修改护理等级")
    public ResponseResult update(NursingLevelDto nursingLevelDto) {
        log.info("修改护理等级{}",nursingLevelDto);
        nursingLevelService.update(nursingLevelDto);
        return success();
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除护理等级")
    public ResponseResult deleteById(@PathVariable Integer id) {
        log.info("删除ID{}",id);
        nursingLevelService.deleteById(id);
        return success();
    }


    @ApiOperation("查询所有护理计划")
    public ResponseResult getList(){

        return ResponseResult.success();
    }
}
